
/** Configkan pada file phpfn8.php   **/
<?php
	//file phpfn8.php
	$mail->FromName = "Info Anaedar [Do Not Reply This Email]";
	$mail->Subject = $sSubject;
	$mail->Body = $sMail;
	if ($sCharset <> "" && strtolower($sCharset) <> "iso-8859-1")
		$mail->CharSet = $sCharset;
	$sToEmail = str_replace(";", ",", $sToEmail);
	$arrTo = explode(",", $sToEmail);
	foreach ($arrTo as $sTo) {
		$mail->AddAddress("undisclosed-recipients:;");
		$mail->AddBCC(trim($sTo));
	}
	
?>	


/** Configkan pada file massmailedit.php   **/
<?php include_once "userinfo.php" ?>
<?php 	
	//find method function EditRow()
	function EditRow() {
		//update code ini
		global $conn, $Security, $Language, $massmail, $user;
		
		.......
		
		//update code ini
		if ($EditRow) {
			if ($massmail->SendEmail){
		
				$sentType = $rsold['sentmail'];
				
				//default - Semua Pengguna
				$sSqlEmail = " user WHERE email is not null ";
				//Pengguna Ahli AnaEdar Sahaja
				if($sentType == 1){
					$sSqlEmail = " user WHERE email is not null and verify_ahli = 'verified' ";
				}
				//Pengguna Bukan Ahli AnaEdar 
				else if($sentType == 2){
					$sSqlEmail = " user WHERE email is not null and verify_ahli != 'verified' ";
				}

				$user =  new cuser();
				$count = '-1';
				$sSqlE = "SELECT COUNT(*) FROM ".$sSqlEmail;
				if ($rs = $conn->Execute($sSqlE)) {
					$count = $rs->RecordCount();
					$rs->Close();
				}

				//$count = $user->GetRecordCount($sSqlEmail);
				$totalEmailPerSend = 50;
		
				$rec = abs($count/$totalEmailPerSend);
		
				$index = 0;
				if($count > 0){
					while($rec > 0){
						$sentTo = "";
						for ($i = 0; $i < $totalEmailPerSend; $i++) {
							if($index <= $count){
								$rs = ew_LoadRecordset("SELECT * FROM user where email is not null limit $index,1");
								if ($rs && !$rs->EOF) {
		
									if($i == 0)
										$sentTo = $rs->fields('email');
									else
										$sentTo = $sentTo.','.$rs->fields('email');
									$rs->Close();
								}
								$index++;
							}
						}
						//echo '<br />'.$sentTo;
						$this->SendEmailBulk($rsold, $rsnew, $sentTo);
						$rec--;
					}
				}
			}
		}
		//$rs->Close();
	}
	
	//Masukkan fucntion ini sekali
	// Send email after update success
	function SendEmailBulk(&$rsold, &$rsnew, $sentTo) {
		global $Language, $massmail, $user;
		$sFn = "phptxt/notify.txt";
	
		$sSubject = $rsnew['title'];
		$sContents = $rsnew['content'];
	
		$Email = new cEmail();
		$Email->Load($sFn);
		$Email->ReplaceSender('info-AnaEdar@powergoat2u.com.my'); // Replace Sender
		$Email->ReplaceRecipient($sentTo); // Replace Recipient
		$Email->ReplaceSubject($sSubject); // Replace Subject
		$Email->Content = $sContents;
		$Email->Format = "html";
		$Email->Charset = EW_EMAIL_CHARSET;
		$Args = array();
		$Args["rsold"] =& $rsold;
		$Args["rsnew"] =& $rsnew;
		$bEmailSent = FALSE;
		if ($massmail->Email_Sending($Email, $Args))
			$bEmailSent = $Email->Send();
	
		// Send email failed
		if (!$bEmailSent)
			$this->setFailureMessage($Email->SendErrDescription);
	}
	
?>

/** Configkan pada file massmailadd.php   **/
<?php include_once "userinfo.php" ?>
<?php 

	// Add record
	function AddRow($rsold = NULL) {
		//update code ini
		global $conn, $Language, $Security, $massmail, $user;
		
		
		..........
		
		
		//update code ini juga
		if ($AddRow) {
			
			// Call Row Inserted event
			$rs = ($rsold == NULL) ? NULL : $rsold->fields;
			$massmail->Row_Inserted($rs, $rsnew);
			if ($massmail->SendEmail){
				
				$sentType = $rs['sentmail'];
				
				//default - Semua Pengguna
				$sSqlEmail = " user WHERE email is not null ";
				//Pengguna Ahli AnaEdar Sahaja
				if($sentType == 1){
					$sSqlEmail = " user WHERE email is not null and verify_ahli = 'verified' ";
				}
				//Pengguna Bukan Ahli AnaEdar 
				else if($sentType == 2){
					$sSqlEmail = " user WHERE email is not null and verify_ahli != 'verified' ";
				}

				$user =  new cuser();
				$count = '-1';
				$sSqlE = "SELECT COUNT(*) FROM ".$sSqlEmail;
				if ($rs = $conn->Execute($sSqlE)) {
					$count = $rs->RecordCount();
					$rs->Close();
				}
				//$count = $user->GetRecordCount($sSqlEmail);

				$totalEmailPerSend = 50;
		
				$rec = abs($count/$totalEmailPerSend);
		
				$index = 0;
				if($count > 0){
					while($rec > 0){
						$sentTo = "";
						for ($i = 0; $i < $totalEmailPerSend; $i++) {
							if($index <= $count){
								$rs = ew_LoadRecordset("SELECT * FROM  $sSqlEmail limit $index,1");
								if ($rs && !$rs->EOF) {
		
									if($i == 0)
										$sentTo = $rs->fields('email');
									else
										$sentTo = $sentTo.','.$rs->fields('email');
									$rs->Close();
								}
								$index++;
							}
						}
						//echo '<br />'.$sentTo;
						$this->SendEmailBulk($rsnew, $sentTo);
						$rec--;
					}
				}
			}
		}
	}
	
	//Masukkan fucntion ini sekali
	// Send email after add success
	function SendEmailBulk(&$rs, $sentTo) {
		global $Language, $massmail, $user;
		$sFn = "phptxt/notify.txt";
	
		$sSubject = $rs['title'];
		$sContents = $rs['content'];
	
		$Email = new cEmail();
		$Email->Load($sFn);
		$Email->ReplaceSender('info-AnaEdar@powergoat2u.com.my'); // Replace Sender
		$Email->ReplaceRecipient($sentTo); // Replace Recipient
		$Email->ReplaceSubject($sSubject); // Replace Subject
		$Email->Content = $sContents;
		$Email->Format = "html";
		$Email->Charset = EW_EMAIL_CHARSET;
		$Args = array();
		$Args["rsold"] =& $rsold;
		$Args["rsnew"] =& $rsnew;
		$bEmailSent = FALSE;
		if ($massmail->Email_Sending($Email, $Args))
			$bEmailSent = $Email->Send();
	
		// Send email failed
		if (!$bEmailSent)
			$this->setFailureMessage($Email->SendErrDescription);
	}

	
	
?>
<?php 
//USERINFO.PHP
//MASUK FUNCTION NIH
//get record count
function GetRecordCount($sSql) {
	global $conn;
	$cnt = -1;
	$sSql = "SELECT COUNT(*) FROM ".$sSql;
	if ($rs = $conn->Execute($sSql)) {
		if (!$rs->EOF && $rs->FieldCount() > 0) {
			$cnt = $rs->fields[0];
			$rs->Close();
		}
	}
	return intval($cnt);
}
?>